package com.hencoder.hencoderpracticedraw1.practice;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

import com.hencoder.hencoderpracticedraw1.R;

public class Practice8DrawArcView extends View {

    public Practice8DrawArcView(Context context) {
        super(context);
    }

    public Practice8DrawArcView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public Practice8DrawArcView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }
    private int w,h;
    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        this.w=w;
        this.h=h;
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        float centerW=w/2;
        float centerH=h/2;
        Paint paint=new Paint();
        paint.setColor(getResources().getColor(R.color.colorAccent));
        Path path=new Path();
        RectF rectF=new RectF(centerW-186,centerH-126,centerW+186,centerH+126);
        path.addArc(rectF,0,180);
        canvas.drawPath(path,paint);
        canvas.drawArc(rectF,250,80,true,paint);
        paint.setStyle(Paint.Style.STROKE);
        path.addArc(rectF,190,60);
        canvas.drawPath(path,paint);
    }
}
